package simulatie;

import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;
/**
 * <table>
 * <tr><td>
 * <tr><td>W & S</td><td>Beweeg Vooruit / Achteruit</td></tr>
 * <tr><td>A & D</td><td>Beweeg Links / Rechts</td></tr>
 * <tr><td>Q & E</td><td>Beweeg Op / Neer</td></tr>
 * <tr><td>/\ & \/</td><td>Draai Op / Neer</td></tr>
 * <tr><td><- & -></td><td>Draai Links / Rechts</td></tr>
 * </table>
 * @author stefantalen
 */
public class InputHandler extends KeyAdapter {
  
  private float x,y;
  public static final int UP = 1;
  public static final int DOWN = 2;
  public static final int LEFT = 3;
  public static final int RIGHT = 4;
  public static final int FORWARD = 5;
  public static final int BACKWARD = 6;
  
  public static final int ROT_UP = 7;
  public static final int ROT_DOWN = 8;
  public static final int ROT_LEFT = 9;
  public static final int ROT_RIGHT = 10;
  public static final int CON_LEFT =11;
  public static final int CON_RIGHT = 12;
  
  
  private int pressedKey = 0;
  
  public InputHandler () {
    super();
  }

  public void mouseDragged (MouseEvent mouseEvent) {
	  
	}

  public void mouseMoved (MouseEvent e) {
	  x = e.getX ();
	  y = e.getY ();  
	}
	
  public float getX() {
	  return x;
	}
	
  public float getY() {
	  return y;
	}
	
  public void keyPressed(KeyEvent e) {
	  switch (e.getKeyCode()) {
            case KeyEvent.VK_W:
                pressedKey = InputHandler.FORWARD;
                break;
            case KeyEvent.VK_S:
                pressedKey = InputHandler.BACKWARD;
                break;
            case KeyEvent.VK_A:
                pressedKey = InputHandler.LEFT;
                break;
            case KeyEvent.VK_D:
                pressedKey = InputHandler.RIGHT;
                break;
            case KeyEvent.VK_Q:
                pressedKey = InputHandler.DOWN;
                break;
		    case KeyEvent.VK_E:
		        pressedKey = InputHandler.UP;
		        break;
		    case KeyEvent.VK_UP:
		        pressedKey = InputHandler.ROT_UP;
		        break;
		    case KeyEvent.VK_DOWN:
		        pressedKey = InputHandler.ROT_DOWN;
		        break;
		    case KeyEvent.VK_LEFT:
		        pressedKey = InputHandler.ROT_LEFT;
		        break;
		    case KeyEvent.VK_RIGHT:
		        pressedKey = InputHandler.ROT_RIGHT;
		        break;
		    case KeyEvent.VK_V:
		        pressedKey = InputHandler.CON_LEFT;
		        break;
		    case KeyEvent.VK_B:
		        pressedKey = InputHandler.CON_RIGHT;
		        break;
	   }
	}
	
  public int getPressedKey() {
    int result = pressedKey;
    pressedKey = 0;
    return result;	  
  } 
}
